/*
 * heap_sort.c
 *
 *  Created on: Mar 25, 2014
 *      Author: jack
 */
#include<stdio.h>

void quick_sort(int arr[],int start,int end) {
	if(start<end) {
		int piv_site=partition(arr,start,end);
		quick_sort(arr,start,piv_site);
		quick_sort(arr,piv_site+1,end);
	}
}

int partition(int arr[],int start,int end) {
	int piv_value = arr[start];
	while(start<end) {
		while(end > start && arr[end]>=piv_value) end--;
		if(end > start) arr[start]=arr[end];
		while(end > start && arr[start]<=piv_value) start++;
		if(end > start) arr[end]=arr[start];
	}
	arr[start]=piv_value;
	return start;
}



